﻿using System;

namespace GenericTypes
{
    class Program
    {
        static void Main(string[] args)
        {
            //int
            Stack<int> intStatck = new Stack<int>();
            intStatck.push(100);
            int popIntValue = intStatck.pop();
            Console.WriteLine("int类型的栈顶值是:"+popIntValue);

            //string
            Stack<string> stringStack = new Stack<string>();
            stringStack.push("Hello");
            string popStringValue = stringStack.pop();
            Console.WriteLine("string类型的栈顶值是:"+popStringValue);

        }
    }

    //模拟Statkc
    public class Stack<T>
    {
        //方法
        int position;
        T[] Data = new T[100];
        public void push(T value)
        {
            Data[position++] = value;
        }

        public T pop()
        {
            return Data[--position];
        }

    }
}
